<?xml version="1.0" encoding="UTF-8"?>
<!--
   - list2antxqy.xsl
   - Build utility for preprocessing tag documents to XQuery
   -
   - Copyright (c) 2011 Erik Hennum. All Rights Reserved.
   -
   - Licensed under the Apache License, Version 2.0 (the "License");
   - you may not use this file except in compliance with the License.
   - You may obtain a copy of the License at
   -
   - http://www.apache.org/licenses/LICENSE-2.0
   -
   - Unless required by applicable law or agreed to in writing, software
   - distributed under the License is distributed on an "AS IS" BASIS,
   - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   - See the License for the specific language governing permissions and
   - limitations under the License.
   -
   - The use of the Apache License does not indicate that this work is
   - associated with the Apache Software Foundation.
   -
  -->
<xsl:stylesheet version="2.0"
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
    xmlns:fn  = "http://www.w3.org/2005/xpath-functions"
    xmlns:xs  = "http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xsl fn xs">

<xsl:param name="basedir"   as="xs:string"/>
<xsl:param name="resultdir" as="xs:string"/>

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="filelist">
  <xsl:text>
</xsl:text>
  <project
        name="expected-{$resultdir}-test"
        default="expected-{$resultdir}"
        basedir="{$basedir}">
    <taskdef name="antxmlunit-task" classname="org.tntbase.antxmlunit.XMLDiffTask"
        classpath="../etc/antxmlunit/antxmlunit.jar:../etc/antxmlunit/xmlunit-1.3.jar"/>
    <target name="expected-{$resultdir}">
      <xsl:comment>Diffing</xsl:comment>
      <xsl:apply-templates select="file" mode="xmlunit"/>
    </target>
  </project>
</xsl:template>

<xsl:template match="file" mode="xmlunit">
  <xsl:variable name="href" select="fn:string(@href)"/>
  
  <echo>Comparing <xsl:value-of select="$href"/></echo>

  <antxmlunit-task>
    <xsl:attribute name="orig"        select="concat('out/expected/',$href)"/>
    <xsl:attribute name="result"      select="concat('out/',$resultdir,'/',$href)"/>
    <xsl:attribute name="failonerror" select="'false'"/>
  </antxmlunit-task> 
</xsl:template>

</xsl:stylesheet>
